/*!
 * jQuery plugins highlight
 *
 *
 * Date: 2014-05-10 XueJingQue
 * 
 */
(function($) {    
  // define plugins
	
  $.fn.hilight = function(options) {    
	  
    debug(this);    
    
    // build main options before element iteration    
    var opts = $.extend({}, $.fn.hilight.defaults, options);
    
    // iterate and reformat each matched element    
    return this.each(function() {
    	
      $this = $(this);    
      
      // build element specific options    
      var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
      
      // update element styles

      $this.css({    
        backgroundColor: o.background,    
        color: o.foreground, 
      });
      
      var markup = $this.html();    
      // call our format function    
      markup = $.fn.hilight.format(markup);    
      $this.html(markup);    
    });    
  };    
  // debugging private
  function debug($obj) {    
    if (window.console && window.console.log)
      
      window.console.log('hilight selection count: ' + $obj.size());    
  };    
  // format function public   
  $.fn.hilight.format = function(txt) {    
    return '<strong>' + txt + '</strong>';    
  };    
  //plugins  defaults    
  $.fn.hilight.defaults = {    
    foreground: 'red',    
    background: 'yellow'
  };    
// end    
})(jQuery);     
